<?php

namespace Action\Contact;

class AnswerDialog extends \Library\Action\UserAction 
	implements \Library\Action\AjaxAction {
	
	private $_contact;
	private $_message;

	public function execute() {
		parent::execute();
		
		$request_id = (int) $this->getParam( 'id' );
		
		$request = \Bean\User\Request::get( $request_id );
		
		if( !$request->getAcceptor()->isMe() ) {
			throw new \Exception( 'This request doesn\'t concern you' );
		}
	
		$this->_message = $request->getMessage();
		$this->_contact = $request->getRequester();
		
		return array(
			'user_id' => $this->_contact->getUserId(),
			'content' => $this->view(),
			'icon' => $this->_contact->getMiniPath()
		);
	}
	
	public function getContact() {
		return $this->_contact;
	}

	public function getMessage() {
		return $this->_message;
	}
}
